Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Featured Medium post should be most recent post #366

Merged
merged 3 commits into from
Nov 8, 2018
Merged

Conversation

austinlparker
Copy link
Member

This adds some dynamic fetching of the Medium RSS feed in order to display the most recent post on the frontpage rather than using the site data supplied URL.

@iredelmeier
Copy link
Member

As a first pass, this works and LGTM.

I do have a couple of concerns:

  • There's some lag between the initial page load and the featured post populating. I think it might actually be worth blocking any rendering (as hesitant as I am to suggest that!) until the blog post is ready, or people are likely may scroll past it without noticing.
  • Pulling in jquery feels very heavyweight. Most browsers now have built-in support for fetch, and there's a polyfill if we're concerned about IE.

Your call on whether those are worth addressing now or not!

@tedsuo
Copy link
Member

tedsuo commented Nov 7, 2018

Some thoughts:

  • I'd prefer this to be a server-side feature, and to generally eliminate JS from the the site.
  • I don't think we should hold up rendering of the page on the client-side to wait for this query, but I do think this approach will create viewing issues, especially on slow/mobile connections.
  • However, as a v1 I think this is totally fine.

@austinlparker
Copy link
Member Author

@iredelmeier to your points -

  • I initially had a dummy 'Check out our Medium blog' style link/text that got replaced by the actual latest post. I felt like the flash of it getting replaced was more jarring than just having the link text appear, but could certainly go back to that.
  • Good call on fetch vs. jq, I'll refactor using that.

@tedsuo

  • my only problem with doing this server-side is that the page is static, so 'server-side' means 'when we build the site', which would require us to manually change the link whenever a new post goes up. historically, it seems like we haven't been doing a great job at being timely with that.

@yurishkuro
Copy link
Member

My vote is for dynamic non-blocking pull via JS (we did the same on https://www.jaegertracing.io/). I don't want to redeploy the site then posts are added to Medium.

@lucperkins
Copy link
Collaborator

lucperkins commented Nov 7, 2018

One possibility worth exploring is rebuilding the site via webhook. We could set up a simple IFTTT applet that POSTs to a Netlify webhook that rebuilds the site.

In terms of presenting a list of posts statically, Hugo has a convenient getJSON function that can pull in post metadata from Medium. I set up the containerd downloads page, for example, to use getJSON to fetch release metadata from the GitHub API.

I've added a webhook in Netlify. The only remaining step would be setting up the IFTTT applet, which I lack permissions to do.

So the flow would be:

New Medium post --> POST to Netlify --> Hugo fetches newest metadata from Medium --> Hugo builds new site --> Netlify publishes

@iredelmeier
Copy link
Member

I like @lucperkins's idea 👍

@austinlparker
Copy link
Member Author

I like the IFTTT idea, are we OK merging with this in its current state to get updates going then I'll work the IFTTT idea?

@lucperkins
Copy link
Collaborator

@austinlparker Yeah, I think best to merge this now. I can re-work the setup to use Hugo to fetch the JSON from the Medium API. The one missing piece would be to set up the IFTTT pipeline, which can only be done by an "owner" of the Medium blog (which I'm not). I've already set up the Netlify webhook. Do you have access to the Netlify dashboard? If not I can email you the private URL for the HTTP endpoint.

@austinlparker
Copy link
Member Author

@lucperkins I've got access to Netlify, yeah. I'll look into getting the IFTTT stuff set up. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants